﻿@model SuperiorModel.ShopRoleModel
@{
    Layout = null;
    
}
<link href="~/layui/css/layui.css" rel="stylesheet" />

<link href="~/Content/extend.css" rel="stylesheet" />

<script src="~/scripts/jquery-1.10.2.js"></script>
<script src="~/scripts/Common/Base.js"></script>
<script src="~/scripts/Common/RequestManager.js"></script>
<script src="~/scripts/Common/ToolManager.js"></script>
<script src="~/scripts/layer/layer.js"></script>
<script src="~/layui/layui.js"></script>
<link href="~/scripts/ShopAdmin/dtree/dtree.css" rel="stylesheet" />
<link href="~/scripts/ShopAdmin/dtree/font/dtreefont.css" rel="stylesheet" />
<div class="shopmain">
    <div class="shopbody">
        <div class="layui-form">
            <ul id="demoTree" class="dtree" data-id="0"></ul>
           

        </div>
    </div>
</div>
<script>
    var dtree; var DemoTree; var jsonList;
    function GetDemoTree() {
        var res = {"DemoTree":DemoTree,"jsonList":jsonList};
        return res;    
    }
    layui.use('form', function () {
        var form = layui.form;
        form.render();
        layui.extend({
            dtree: '{/}/scripts/ShopAdmin/dtree/dtree'   // {/}的意思即代表采用自有路径，即不跟随 base 路径
        }).use(['dtree', 'layer', 'jquery'], function () {
            dtree = layui.dtree, layer = layui.layer, $ = layui.jquery;
            var objJson = '@Html.Raw(Json.Encode(Model.AuthoritysList))'
             jsonList = eval('(' + objJson + ')');//由JSON字符串转换为JSON对象
            DemoTree = dtree.render({
                elem: "#demoTree",
                data: jsonList,
                type: "all",
                initLevel: "5",
                dataStyle: "layuiStyle",  //使用layui风格的数据格式
                dataFormat: "list",  //配置data的风格为list
                response: { message: "msg", statusCode: 0 },  //修改response中返回数据的定义
                checkbar: true //开启复选框
            });

            dtree.on("node('demoTree')", function (obj) {
                layer.msg(JSON.stringify(obj.param));
            });
        });
        form.on('checkbox(check_all)', function (data) {
            $("input[name=check_area]").each(function (index, item) {
                item.checked = data.elem.checked;
                form.render('checkbox');//真JB蛋疼，必须渲染一下，
            });
        });

    });
   
   
</script>

